<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php echo $this->Facebook->html(); ?>
<head>

    <?php echo $this->Html->charset(); ?>

    <title>
        <?php echo $title_for_layout; ?>
    </title>

    <meta name="viewport" content="width=device-width, initial-scale =1.0">
        <meta name="keywords" content="Tattlr,Twitter,CoolSoft">
            <meta name ="author" content ="CoolSoft2012">

                <?php
                # Import javascript and css files.
                echo $this->Html->script(array('jquery-1.7.2.min',
                    'jquery-ui-1.8.19.custom.min',
                    'bootstrap.min'));
                echo $this->Html->css(array('bootstrap.min',
                    'jquery-ui-1.8.19.custom.css'));
                echo $this->Html->meta('icon');

                # Fetch the imported files.
                echo $this->fetch('meta');
                echo $this->fetch('css');
                echo $this->fetch('script');
                ?>

                <!-- Le styles -->
                <style type="text/css">
                    body {
                        padding-top: 60px;
                        padding-bottom: 40px;
                    }
                </style>
<?php echo $this->Html->css('bootstrap.min'); ?>
                </head>


                <body>
                    <div class="navbar navbar-fixed-top">
                        <div class="navbar-inner">
                            <div class="container-fluid">
                                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                </a><!--btn-navbar-->
                                <a class="brand" href="http://tattlr.com">Tattlr</a>
                                <div class="nav-collapse">
                                    <ul class="nav">
                                        <li><a href="#" id = "dash"><i  class ="icon-home icon-white"></i> Dashboard</a></li>
                                        <li><a href="#" id="home">Home Timeline</a></li>
                                        <li><a href="#" id="followers">View followers</a></li>
                                        <li><a href="/Tweets">Search</a></li>
                                        <?php if ($ad == 0) { ?>
                                            <li><a href="/tasks/viewAll">Tasks</a></li>
                                        <?php } ?>		
                                        <li><a href="/FutureDms/">View DMs</a></li>
                                        <li><a href="/FutureTweets">FutureTweets</a></li>
                                        <li><a href="/events">Events</a></li>

                                        <?php if ($ad == 1) { ?>
                                            <li><a href="/tattlraccounts/">Admin</a></li>
                                        <?php } ?>
                                        <li><a href="/Users/logout">Logout</a></li>
                                        <li><a href="/tattlraccounts/db">.</a></li>
                                        <li> <?php echo $this->Facebook->login(); ?> </li>
                                        <li> <?php echo $this->Facebook->logout(); ?> </li>											
                                    </ul>
                                </div> 
                            </div><!--container-->
                        </div><!--.navbar-inner-->
                    </div><!--navbar-->
                    <div class ="container-fluid2">
                        <div class ="row-fluid">
                            <div class ="span3">
                                <?php echo $this->fetch('content1'); ?>

                            </div><!--span3-->

                            <div class="span6">
                                <div id = "Test" class = "Notification" ></div>

                                <?php echo $this->Session->flash(); ?>
                                <?php echo $this->Session->flash('auth'); ?>
                                <?php echo $this->fetch('content'); ?>
                                <?php echo $this->fetch('content2'); ?>
                                <?php echo $this->fetch('content3'); ?>

                            </div><!--span6-->

                            <div class="span3 offset4">
                                <div class="well pull-right">
                                    <ul class="nav nav-list">
                                        <li class="nav-header">
                                            Filters
                                        </li>
                                        <li><?php echo $this->Html->link('All filters', array('controller' => 'Posts', 'action' => 'allfilters')); ?></li>
                                        <li><?php echo $this->Html->link('Filter tweets by User', array('controller' => 'Users', 'action' => 'viewUsers')); ?></li>
                                        <li><?php echo $this->Html->link('Filter by account', array('controller' => 'Accounts', 'action' => 'filteraccount')); ?></li>
                                        <li><?php echo $this->Html->link('Filter DMs by account', array('controller' => 'Accounts', 'action' => 'viewClients')); ?></li>
                                        <li class="nav-header">
                                            Accounts
                                        </li><?php for ($i = 0; $i < count($accounts); $i++) { ?>  <?php
                                    echo $this->Form->create('tattlrAccount', array('action' => 'selectAccount'));
                                    echo $this->Form->hidden('Account', array('value' => $accounts[$i]));
                                    echo $this->Form->submit($images[$i]) . "" . $accounts[$i];
                                    echo $this->Form->end();
                                    ?>  <?php
                                    }
                                ?>
                                    </ul>
                                </div>
                            </div><!--span3-->
                        </div><!--row-->
                    </div>
                    <script type="text/javascript">
                        $(document).ready(function() {
                            $.ajaxSetup({
                                cache: true
                            });

                            //Loading Image.
                            var ajax_load = "<img src='http://d2o0t5hpnwv4c1.cloudfront.net/412_ajaxCalls/DEMO/img/load.gif' alt='loading...' style='top:48%; left:48%; position:relative;'/>";

                            //PHP file URL.
                            var loadUrl = "/Posts/index";
                            var loadUrl2 = "/Posts/fetchHome";
                            var loadUrl3 = "/accounts/getFollowers";
 
                            $(document).on("click", "#dash", function(){ 
                                $(".container-fluid2").html(ajax_load);  
                                $.get(  
                                loadUrl,  
                                {language: "php", version: 5},  
                                function(responseText){  
                                    $(".container-fluid2").html(responseText);
                                    $("#CancelReply").hide();
                                    history.replaceState(null, "Dashboard", "/posts");
                                    $(document).attr('title','Dashboard');
                                },  
                                "html"  
                            ); 
                            });
                            $(document).on("click", "#home", function(){ 
                                $(".container-fluid2").html(ajax_load);  
                                $.get(  
                                loadUrl2,
                                {language: "php", version: 5},  
                                function(responseText){  
                                    $(".container-fluid2").html(responseText);
                                    $("#CancelReply").hide();
                                    history.replaceState(null, "Timeline", "/posts/fetchHome");
                                    $(document).attr('title','Timeline');
                                },  
                                "html"  
                            );  
                            });  
                            $(document).on("click", "#followers", function(){
                                $(".container-fluid2").html(ajax_load);  
                                $.get(  
                                loadUrl3,  
                                {language: "php", version: 5},  
                                function(responseText){  
                                    $(".container-fluid2").html(responseText); 
                                    $("#CancelReply").hide();
                                    history.replaceState(null, "View followers", "/accounts/getFollowers");
                                    $(document).attr('title','Followers');
                                },  
                                "html"  
                            );  
                            });  
                        });  
                    </script>
                </body>
                <footer>
                    <?php echo $this->element('sql_dump'); ?>
                </footer>
                <?php echo $this->Facebook->init(); ?>
                </html>
